package customer.zspt.cn.customer.components.chat.ChatOrderContent.OrderElementPg;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import customer.zspt.cn.customer.R;

/**
 * Created by Administrator on 2018/8/16 0016.
 */

public class NumberInputView extends BaseView implements OnClickListener{
    private  TextView title;
    //减
    private  TextView reduce;
    //加
    private TextView add;
    //数字
    private TextView number;
    public NumberInputView(Context context,String titleValues,String defaultVaules) {
        super(context,titleValues);
        View.inflate(context, R.layout.chat_order_content_numberinput,this);
        title = (TextView)findViewById(R.id.title);
        reduce = (TextView) findViewById(R.id.reduce);
        add = (TextView) findViewById(R.id.add);
        number = (TextView) findViewById(R.id.number);
        number.setText(defaultVaules);
        title.setText(titleValues);
        reduce.setOnClickListener(this);
        add.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        int numberical = Integer.parseInt(number.getText().toString());
         switch (v.getId()){
             case R.id.reduce:
                 numberical -= 1 ;
                 number.setText(numberical+"");
                 break;
             case R.id.add:
                 numberical += 1 ;
                 number.setText(numberical+"");
                 break;
         }
    }
    public String result(){
        return number.getText().toString();
    }

}
